package tt.dz.egobus.servicemanager.business.convert;

import org.apache.commons.lang3.StringUtils;
import tt.dz.egobus.servicemanager.bean.RedisTopicMessage;
import tt.dz.egobus.servicemanager.bean.SpringConfigConstant;

/**
 * @author Anson
 * @date 17-9-7
 * @name 业务流水号转换成当前业务过期的事件监听器的KEY
 * @since 1.0.7
 */
public class BusinessIdRedisTopicMessageConverter implements MessageEventConverter<String, RedisTopicMessage> {


    @Override
    public RedisTopicMessage convert(String businessId) {
        RedisTopicMessage redisTopicMessage = new RedisTopicMessage();
        if (StringUtils.isAnyEmpty(businessId)) {
            return redisTopicMessage;
        }
        redisTopicMessage.setBusinessKey(businessId);
        redisTopicMessage.setEventName(this.eventKey());
        redisTopicMessage.setCreateTime(System.currentTimeMillis());
        redisTopicMessage.setChannel(SpringConfigConstant.EXPIRE_REDIS_KEY);
        redisTopicMessage.setRedisPre(SpringConfigConstant.APP_COMMON_PRE);
        return redisTopicMessage;
    }

    @Override
    public String eventKey() {
        return SpringConfigConstant.BUSINESS_MSG_NOTIFY_KEY;
    }

}
